{% extends 'IcsocUIBundle::page.html.twig' %}
{% block content %}
    <div class="text-center alert alert-{{ datavalue.type }}">
        <p id="redirectionMsg">
            {% if datavalue.auto_redirect %}如果您不做出选择，将在 <span id="spanSeconds">5</span> 秒后跳转到第一个链接地址。{% endif %}
        </p>
        <p>
            <span style="color: red">{{ datavalue.msg_detail }}</span>
        </p>
        <p>
            {% for link in datavalue.link %}
                <a class="btn btn-sm btn-success" href="{% if link.type is defined %}javascript:window.parent.location.href='{{ link.href }}'{% else %}{{ link.href }}{% endif %}">{{ link.text }}</a>&nbsp;&nbsp;&nbsp;
            {% endfor %}
        </p>
    </div>
{% endblock %}
{% block footer %}
        {% if datavalue.auto_redirect %}
        <script language="JavaScript">
            <!--
            var seconds = 5;
            var defaultUrl = "{{ datavalue.default_url }}";
            var intervalId = null;
            onload = function()
            {
                if (defaultUrl == 'javascript:history.go(-1)' && window.history.length == 0)
                {
                    document.getElementById('redirectionMsg').innerHTML = '';
                    return;
                }
                intervalId = window.setInterval(redirection, 1000);
            };
            function redirection()
            {
                if (seconds <= 0)
                {
                    window.clearInterval(intervalId);
                    return;
                }

                seconds--;
                document.getElementById('spanSeconds').innerHTML = '"' + seconds + '"';

                if (seconds == 0)
                {
                    window.clearInterval(intervalId);
                    {% if datavalue.link_type == 1 %}
                        window.parent.location.href = defaultUrl;
                    {% else %}
                        location.href = defaultUrl;
                    {% endif %}

                }
            }
        //-->
    </script>
    {% endif %}
{% endblock %}